package Project4;
import java.util.*;

public class Method{
	private String name = "DEFAULT_METHOD_NAME";
	private String type = "DEFAULT_METHOD_TYPE";
	private ArrayList<Variable> parameters = new ArrayList<Variable>();
	private Hashtable<String, Variable> localVariables = new Hashtable<String, Variable>();

	public Method(String name, String returnType){
		this.name = name;
		this.type = returnType;
	}

	public String getName(){
		return this.name;
	}

	public String getType(){
		return this.type;
	}

	public void addParam(Variable v){
		parameters.add(v);
	}

	public void addVar(Variable v){
		localVariables.put(v.getName(), v);
	}

	public boolean containsParam(String id){
		for(int i = 0; i < parameters.size(); i++){
			if(parameters.get(i).getName().equals(id)){
				return true;
			}
		}

		return false;
	}

	public boolean containsVar(String id){
		return localVariables.containsKey(id);
	}

	public ArrayList<Variable> getParams(){
		return this.parameters;
	}

	public Variable getParam(String id){
		for(int i = 0; i < parameters.size(); i++){
			if(parameters.get(i).getName().equals(id)){
				return parameters.get(i);
			}
		}

		return null;
	}

	public Variable getVar(String id){
		return localVariables.get(id);
	}
} 
